package com.jlnx.controller.chain;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jlnx.dao.ChainEnterpriseDaoImpl;
import com.jlnx.dao.CoreEnterpriseDaoImpl;
import com.jlnx.dao.EnterpriseDaoImpl;
import com.jlnx.dao.FinanceReqDaoImpl;
import com.jlnx.pojo.ChainEnterprise;
import com.jlnx.pojo.CoreEnterprise;
import com.jlnx.pojo.Enterprise;
import com.jlnx.pojo.FinanceReq;


@WebServlet("/SaveChainEntMsgController")
public class SaveChainEntMsgController extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		//获取请求信息
		response.setContentType("charset=UTF-8");
		//设置请求编码模式
    	request.setCharacterEncoding("utf-8");
    	String entNo = request.getParameter("entNo");
		String phoneNo = request.getParameter("phoneNo");
		String propertyStr = request.getParameter("property");
		String salesStr = request.getParameter("sales");
		
		System.out.println("保存信息：" + entNo);
		
		BigDecimal property = null;
		BigDecimal sales = null;
		
		if(propertyStr != null && propertyStr != "") {
			property = new BigDecimal(propertyStr);
		}
		
		if(salesStr != null && salesStr != "") {
			sales = new BigDecimal(salesStr);
		}
		
		ChainEnterpriseDaoImpl dao = new ChainEnterpriseDaoImpl();
		ChainEnterprise chainEnterprise = dao.selectByEntNo(entNo);
		chainEnterprise.setPhoneNo(phoneNo);
		chainEnterprise.setProperty(property);
		chainEnterprise.setSales(sales);
				
		 //插入准入请求信息
		if(dao.updateChainEntMessage(chainEnterprise) < 0) {
			request.getRequestDispatcher("/getChainEntMessageController").forward(request, response);
			
		}else {
			request.getRequestDispatcher("/getChainEntMessageController").forward(request, response);
		}
				
	}

}
